<script language="javascript">
function qtyCheck(qtyObj,SuppliedObj)
{
	//var qtySupplied = SuppliedObj - (SuppliedObj - 10);
	var qtyTaken = parseInt($(qtyObj).val());
	if(qtyTaken > parseInt(SuppliedObj))
	{
		alert("Quantity Return Cannot Be Greater");
		$(qtyObj).focus();
		return false;
	}
}  

$(function()
{
  // add multiple select / deselect functionality
  $(".selectall").click(function () {
    $('.case'+$(this).val()).attr('checked', this.checked);
  });
  // add multiple select / deselect functionality End
});
</script>
<br />
{section name="sec" loop=$deliveryChallanArray}
  {if $deliveryChallanArray[sec].display == 1}
		<table align="center"  border="1">
		<tr>
		  <td class="table4" align="center">&nbsp;</td>
		  <td class="table4" align='center'><B>Sr. Record No.</td>
		  <td class="table4" align='center'><B>Customer</td>
			<td class="table4" align='center'><B>Challan No.</td>
			<td class="table4" align='center'><B>Date</td>
			<td class="table4" align='center'><B>Challan Type</td>
		</tr>
		<tr>
		  <td class="table3">
		    <input type="checkbox" class="selectall" name="deliveryChallanMasterId[]" value="{$deliveryChallanArray[sec].deliveryChallanMasterId}" />
		  </td>  
		  <td class="table3" align="center">{$smarty.section.sec.rownum}</td>
		  <td class="table3" align="left">{$deliveryChallanArray[sec].companyName}</td>
		  <td class="table3" align="right">{$deliveryChallanArray[sec].srNo}</td>
		  <td class="table3" align="right">{$deliveryChallanArray[sec].delivaryDate}</td>
		  <td class="table3" align="center">{$deliveryChallanArray[sec].challanType}</td>
		</tr>
		<tr>
		  <table align="center" border="1">
		    <tr>
		      <th class="table1">&nbsp;</th>
		      <th align="left"  class="table1">SubCategory</th>
		      <th align="center" class="table1">Item</th>
		      <th align="center" class="table1">Quantity Supplied</th>
		      <th class="table1">Quantity Return</th>
		    </tr>
		    {assign var="countVar" value="0"}
		    {section name="sec1" loop=$deliveryDetailArray[sec]}
		     <input type="hidden" name="countVar" value="{$countVar++}">
		      <tr>
		        <td class="table3">
		          <input type="checkbox" class="case{$deliveryChallanArray[sec].deliveryChallanMasterId}" id="deliveryChallanDetailId[]" 
		           name="deliveryChallanDetailId[{$deliveryDetailArray[sec][sec1].deliveryChallanDetailId}]" value="{$deliveryDetailArray[sec][sec1].deliveryChallanDetailId}" />
		        </td> 
		        <td class="table3">{$deliveryDetailArray[sec][sec1].subCategoryName}</td>
		        <td class="table3" NOWRAP>{$deliveryDetailArray[sec][sec1].itemName}</td>
		        <td class="table3" align="right">{$deliveryDetailArray[sec][sec1].quantity}</td>
		        <input type="hidden" name="qtySupplied[]" id="qtySupplied[]" class="qtySupplied" size="2" value="{$deliveryDetailArray[sec][sec1].quantity}" />
		        <td class="table3" align="center">
		          <input type="text" name="qtyTaken[{$deliveryDetailArray[sec][sec1].deliveryChallanDetailId}]" id="qtyTaken" class="qtyTaken" size="2" onblur="qtyCheck(this,'{$deliveryDetailArray[sec][sec1].quantity}');"/>
		        </td>
		      </tr>
		    {/section}
		  </table>
		</tr>
		</table>
	{/if}
{/section}
{if $countVar == 0}
	<tr class="table2">
	  <td align="center" colspan="10"><h2><center><font color="red"><b>{$msg}</b></font></center></h2></td>
	</tr>
{/if}
{if $countVar != 0}
<br />
  <center><input type="submit" name="submitDateBtn" value="Submit" class="button"/></center>
{/if}